
#include "chapter1_2.h"
using namespace std;



template <class elemType>
class Array{

	public:
		Array(int size = 10);
		Array(const Array &rhs);
		Array(elemType *arry, int size);
		Array & operator=(const Array&);

		virtual ~Array() {delete [] ia;}
		bool operator==(const Array&) const;
		bool operator!=(const Array&) const;
		virtual elemType & operator[] (int index) {return ia[index]; }

	protected:
		int _size;
		elemType *ia;


};
/*
Array::Array( int size)
{
	ia = new elemType[size];

}
*/



struct phoneInfo{
	int number;
	string name;
};

class phoneBookManage
{
	private:
		//static struct phoneInfo defaultInfo = {0, "a"};
		vector<phoneInfo> phoneBook;

	public:
		phoneBookManage();
		~phoneBookManage() {};
		void add_entry( int n);
		void printf_info(string name);
		void printf_info(int num);

};
phoneBookManage::phoneBookManage()
{
	struct phoneInfo defaultInfo = {0, "N/A"};

	vector<phoneInfo> phoneBookInit(100, defaultInfo);
	phoneBook = phoneBookInit;

}


void testContainer()
{
	struct phoneInfo defaultInfo = {0, "no name"};

	void testAbstractContaner();
	
	testAbstractContaner();


	vector<phoneInfo> phoneBook1(100, defaultInfo);
	vector<phoneInfo> phoneBook2[100];//, defaultInfo);
	phoneBook1.push_back(defaultInfo);
	//phoneBook.(phoneBook2.size() + 1);
	phoneBookManage MyPhoneBook;
	
	vector<int> ivec0;
	vector<int> ivec(10);
	vector<int> iivec(20, 1);
	vector<int> iiivec(iivec);
	vector<double> fvec(10,0.21);
	vector<char*> strVec(10);

	ivec0.reserve(32);
	ivec0.push_back(0xffff);
	vector<int>::iterator it;
	int in = 0;
	//for((cin>>in);  in != 0xff; (cin>>in))
	//	ivec0.push_back(in);

	it = ivec.begin();	
	ivec.insert(it,2, 0xff);
	ivec.insert(ivec.begin(),0xee);
	ivec.insert(ivec.begin() + 5,0xee);

	vector<string> svec;
	string initstr[4] = {"1","2","3","4"};
	svec.insert(svec.begin(),initstr, initstr + 4);
	vector<string> svec2(initstr, initstr + 4);
	vector<string>::iterator itt;
	itt = std::find(svec2.begin(), svec2.end(), "4");
	svec2.erase(itt);
	svec2.swap(svec);
	svec2 = svec;




	list<string> init(10,"Yeah! C++ !");
	init.push_front("begin");
	init.push_back("end");
	list<string>::iterator itstr;
	for(itstr = init.begin(); itstr != init.end(); itstr++)
		cout<<*itstr<<"\n";

	
	init.end();
	list<string> mycpp(init);//creat same list as init, same size, same default value
	list<string> custom_name(256,"N/A");
	string instr;
	int i = 0;
	/* get word once time */
	//for((cin>>instr);  instr != "end"; (cin>>instr), i++)
	//	init.push_back(instr);

	/* get line once time */
	char inlinestr[256];
	for( ; (strcmp(inlinestr, "end") != 0) ; )
	{		
		
		cin.getline(inlinestr,256,'\n');
		instr = inlinestr;
		init.push_back(instr);		
	}
	
	return;
}


